<div id="admin" style="width: 100%;height: 100%;">

					<div class="panel panel-default">
						<div class="panel-heading">
							会员列表
						</div>

						<div class="navbar-form navbar-left" role="search">
							<div class="form-group">
								<input type="text" class="form-control" id="userIdText" placeholder="请输入钱包id">
								<input type="text" class="form-control" id="usernameText" placeholder="请输入用户名称">
								<input type="text" class="form-control" id="phoneText" placeholder="请输入用户电话">
								<input type="text" class="form-control" id="moneyText" placeholder="请输入起始币数">
								<input type="text" class="form-control" id="moneyEndText" placeholder="请输入结束币数">
							</div>
							 <button type="button" onclick="ready('','');" style="" class="btn btn-default">搜索</button>
                             <button onclick="closeWindow();" class="btn btn-success" id="btn_add" data-toggle="modal"><i class="glyphicon glyphicon-plus"></i>&nbsp;新增</button>
						</div>
						<!-- /.panel-heading -->
						<div class="panel-body">
							<div class="table-responsive" style="height:600px;">
								<table class="table">
									<thead>
										<tr>
											<th>#</th>
											<th>钱包id</th>
											<th>用户名称</th>
											<th>电话</th>
											<th>状态</th>
											<th>等级</th>
											<th>ec币数</th>
											<th>注册时间</th>
											<th>最近登录时间</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody id="admin_tbody">
									
									</tbody>
								</table>
							</div>
							<!-- /.table-responsive -->
						</div>
						<!-- /.panel-body -->
					</div>

					 <div style="text-align:right">
	                    <span style="margin-right:30px;">当前是：01页</span>
	                    <ul class="pagination pagination-sm" id="paging" style="vertical-align:middle;">
						<li><a href="#">&laquo;</a></li>
						<li><a href="#">1</a></li>
						<li><a href="#">2</a></li>
						<li><a href="#">3</a></li>
						<li><a href="#">4</a></li>
						<li><a href="#">5</a></li>
						<li><a href="#">&raquo;</a></li>
				       </ul>
                    </div>
					
					
					
					
					<div class='pop' id="pop">
						<div class='box'>
							<div class="modal-header">
									用户详情
									<button type="button" onclick="closeWindow();" class="close" data-dismiss="modal" aria-hidden="true">×</button>
									<h4 class="modal-title" id="myModalLabel"></h4>
								</div>
								<div>
									<div><label>钱包账号:</label><span id="userId"></span></div>
								    <div><label>用户名称:</label><span id="username"></span></div>
								    <div><label>ec币个数:</label><span id="ecs"></span></div>
								    <div><label>性别:</label><span id="sex"></span></div>
								    <div><label>年龄:</label><span id="age"></span></div>
								    <div><label>电话:</label><span id="phone"></span></div>
								    <div><label>头像:</label><span id="photo"></span></div>
								    <div><label>用户状态:</label><span id="state"></span></div>
								    <div><label>账户等级:</label><span id="grade"></span></div>
								    <div><label>积分:</label><span id="integral"></span></div>
								    <div><label>创建时间:</label><span id="date"></span></div>
								    <div><label>二维码:</label><span id="userQrCode"></span></div>
								    <div><label>备注:</label><span id="flag"></span></div>
								    <div><label>登录时间:</label><span id="loginDate"></span></div>
								    <div><label>交易地址:</label><span id="receivablesAddress"></span></div>
								    <div><label>备注:</label><span id="remark"></span></div>
								    <div><label>钱包个数:</label><span id="count"></span></div>
								    <div><label>钱包备注:</label><span id=payFlag></span></div>
								  <div class="modal-footer">
									<button id="closeW" type="button" class="btn btn-default" onclick="closeWindow();">关闭</button>
									<button type="button" id="submit" onclick="addAdmin();" class="btn btn-primary">提交</button>
								</div>
							</div>
							
						</div>
					</div>
					

<script type="text/javascript">

	//页面加载执行数据渲染	
	$(function(){ 
		ready("","");
	}); 
	
	
	//界面加载方法
	function ready(currentPageNum,totle){
		
		// 分页参数设定
		if(currentPageNum=="" || currentPageNum==null){
			currentPageNum=1;
		}
		
		// 分页参数设定
		if(totle=="" || totle==null){
			totle=10;
		}
		
		var userId= $("#userIdText").val();
		var username= $("#usernameText").val();
		var phone= $("#phoneText").val();
		var money= $("#moneyText").val();
		var moneyEnd= $("#moneyEndText").val();
		var data={'currentPageNum':currentPageNum,'perPageSize':totle,'perPageSize':totle,'userId':userId,'username':username,'phone':phone,'money':money,'moneyEnd':moneyEnd};
		$.ajax({  
		    type:'post',    
		    url:'/User/selectByAll.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	Data_assembly(data);
		    	footer(data.data.totalPageNum,data.data.currentPageNum);
		    }  
		  });
	}
	
	//数据组装方法
	function Data_assembly(data){
		  console.log(data);
		  console.log(tbody);
		  var tbody=data.data.entitys;
		  var html="";
		  var b=1;
		  for(var i=0;i<tbody.length;i++){
			  html+='<tr>';
			  html+='<td>'+b+'</td>';
			  html+='<td>'+tbody[i].userId+'</td>';
			  html+='<td>'+tbody[i].username+'</td>';
			  html+='<td>'+tbody[i].phone+'</td>';
			  if(tbody[i].state==1){
				  html+='<td>启用</td>';
			  }else{
				  html+='<td>禁用</td>';
			  }
			  html+='<td>'+tbody[i].grade+'</td>';
			  html+='<td>'+tbody[i].money+'</td>';
			  html+='<td>'+tbody[i].date+'</td>';
			  html+='<td>'+tbody[i].loginDate+'</td>';
			  
			 // html+='<td>'+tbody[i].state+'</td>';
			  if(tbody[i].flag==0){
				  html+='<td><button type="button" onclick="updateState('+"'"+tbody[i].id+"',1"+');" class="btn btn-danger">禁用</button>&nbsp;&nbsp;'
			  }else{
				  html+='<td><button type="button" onclick="updateState('+"'"+tbody[i].id+"',0"+');" class="btn btn-warning">启用</button>&nbsp;&nbsp;'
			  }
			  
			  html+='<button type="button" onclick="userDetails('+"'"+tbody[i].id+"'"+');" class="btn btn-success">详情</button></td>';
			  html+='</tr>';
			  b++;
		  }
		  
		  $("#admin_tbody").html(html);
	}
	
	//修改状态
	function updateState(id,state){
		
		if(id==null || id==''){
			return;
		}
		
		var data={'id':id,'flag':state};
		
		$.ajax({  
		    type:'post',    
		    url:'/User/updateBillState.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	alert(data.msg);
		    	ready("","");
		    }  
		  });
	}
	
	
	//详情
	function userDetails(id){
		var data={'id':id};
		
		$.ajax({  
		    type:'post',    
		    url:'/User/selectByAll.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	 var tbody=data.data.entitys;
		    	 $("#userId").html(tbody[0].userId);
	    		 $("#username").html(tbody[0].username);
	    		 $("#age").html(tbody[0].age);
	    		 $("#phone").html(tbody[0].phone);
	    		 $("#photo").html(tbody[0].photo);
	    		 $("#paymentPassword").html(tbody[0].paymentPassword);
	    		 if(tbody[0].sex==0){
	    			 $("#sex").html("男");
	    		 }else if(tbody[0].type==1){
	    			 $("#sex").html("女");
	    		 }else{
	    			 $("#sex").html("未知");
	    		 }
	    		 
	    		 if(tbody[0].state==0){
	    			 $("#state").html("启用");
	    		 }else if(tbody[0].type==1){
	    			 $("#state").html("禁用");
	    		 }else{
	    			 $("#state").html("未知");
	    		 }
	    		
	    		 $("#grade").html(tbody[0].grade);
	    		 $("#endDate").html(tbody[0].endDate);
	    		 if(tbody[0].flag==0){
	    			 $("#flag").html("启用");
	    		 }else if(tbody[0].type==1){
	    			 $("#flag").html("禁用");
	    		 }else{
	    			 $("#flag").html("未知");
	    		 }
	    		 $("#integral").html(tbody[0].integral);
	    		 $("#date").html(tbody[0].date);
	    		 $("#userQrCode").html(tbody[0].userQrCode);
	    		 $("#loginDate").html(tbody[0].loginDate);
	    		 $("#receivablesAddress").html(tbody[0].receivablesAddress);
	    		 $("#count").html(tbody[0].count);
	    		 $("#payFlag").html(tbody[0].payFlag);
	    		 $("#ecs").html(tbody[0].money);
			     closeWindow();
		    	 
		    }  
		  });
	}
	
	//关闭弹出层
	function closeWindow(){
		$("#pop").fadeToggle();
	}
	
	//分页页脚生成方法
	//dataSize 总页数
	//unmSize 当前所在页数
	function footer(dataSize, unmSize) {
		$("#paging").find("li").remove();
		var html = '<li><a href="javascript:skip(1,' + unmSize + ',' + dataSize
				+ ');">&laquo;</a></li>';
		$("#paging").append(html);

		var number = 12;

		// 判断生成前面部分页脚
		if (unmSize > 5) {
			html = '<li><a href="javascript:skip(0,1);">1</a></li>';
			$("#paging").append(html);
			html = '<li><a href="javascript:skip(0,2);">2</a></li>';
			$("#paging").append(html);
			html = '<li><a href="javascript:void(0);">...</a></li>';
			$("#paging").append(html);
			number = number - 3;
			// 循环生成前半部分
			for (var i = 3; i > 0; i--) {
				if (unmSize - 2 - i > 3) {
					for (i; i > 0; i--) {
						number--;
						var finlSize = unmSize;
						finlSize = finlSize - i;
						html = '<li><a href="javascript:skip(0,' + finlSize + ','
								+ dataSize + ');">' + finlSize + '</a></li>';
						$("#paging").append(html);
					}
					break;
				}
			}

		} else {
			for (var i = 1; i < unmSize; i++) {
				number--;
				html = '<li><a href="javascript:skip(0,' + i + ',' + dataSize
						+ ');">' + i + '</a></li>';
				$("#paging").append(html);
			}
		}

		// 生成当前页
		html = '<li><a style="color:#000;" href="javascript:skip(0,' + unmSize
				+ ',' + dataSize + ');">' + unmSize + '</a></li>';
		$("#paging").append(html);

		// 循环生成后半部分
		for (var i = number; i > 0; i--) {

			if (unmSize + i <= dataSize) {
				number = i;
				var size = unmSize;
				for (i; i > 0; i--) {
					size = size + 1;
					html = '<li><a href="javascript:skip(0,' + size + ','
							+ dataSize + ');">' + size + '</a></li>';
					$("#paging").append(html);
				}
			}
		}

		// 判断生成最后部分页脚
		var endNumber = dataSize - unmSize - number;
		if (endNumber > 3) {
			// 尾部长度超出三个，用省略号代替
			html = '<li><a href="javascript:void(0);">...</a></li>';
			$("#paging").append(html);
			var endSize = dataSize - 1;
			html = '<li><a href="javascript:skip(0,' + endSize + ');">' + endSize
					+ '</a></li>';
			$("#paging").append(html);
			html = '<li><a href="javascript:skip(0,' + dataSize + ');">' + dataSize
					+ '</a></li>';
			$("#paging").append(html);

		} else {
			// 尾部长度没有超出三个，不用省略号
			for (var i = endNumber; i > 0; i--) {
				html = '<li><a href="javascript:skip(0,' + dataSize + ');">'
						+ dataSize + '</a></li>';
				$("#paging").append(html);
				dataSize = dataSize - i;
			}
		}
		html = '<li><a href="javascript:skip(2,' + unmSize + ',' + dataSize
				+ ');">&raquo;</a></li>';
		$("#paging").append(html);
	}



	//分页前置配参执行方法
	function skip(type, num, dataSize) {
		if (type == 1) {
			if (num > 1) {
				num = num - 1
			}else{
				return;
			}
			ready(num,10);
		} else if (type == 2) {

			if (num < dataSize) {
				num = num + 1
				var data={'currentPageNum':num};
				ready(num,10);
			}else{
				return;
			}
		} else if (type == 0) {
			ready(num,10);
		} else {

		}

	}

</script>